import {
    requestLogin,
    requestUserName,
    requestLogOut
} from "@/api"
export const actions = {
    async getToken({
        commit
    }, value) {
        const result = await requestLogin(value)
        commit("GET_TOKEN", result.token)
        //数据持久化保存token
        localStorage.setItem("user_Token",result.token)
    },
    async getUserName({
        commit
    }) {
        const result = await requestUserName()
        commit("GET_USERNAME", result.name)
    },
    async getLogOut({
        commit
    }) {
        await requestLogOut()
        commit("GET_TOKEN", '')
        commit("GET_USERNAME", '')
        localStorage.removeItem("user_Token")
    },
}